package com.fire.control.system.module.company.dao;

import java.util.Collection;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.fire.control.system.entity.Company;

/**
 * @author liuxincheng
 * @ClassName: CompanyRepository
 * @Description: TODO(企业持久层)
 * @author A18ccms a18ccms_gmail_com
 * @date 2017年5月9日 下午2:13:20
 */
@Repository 
public interface ManagementRepository extends JpaRepository<Company, String> ,JpaSpecificationExecutor<Company>{

	/*@Query("from Company c where c.loginName = :loginName and c.password= :password")
	public Company findByLoginNameAndPassword(@Param("loginName")String loginName,@Param("password")String password);
	*/
	@Query("from Company c where c.companyName = :companyname and c.status = :status")
	public Collection<Company> findCompanyByCondition(@Param("companyname")String name,@Param("status")boolean status);
	
	@Modifying(clearAutomatically = true)
	@Query("update Company c set c.status =:status where c.id = :id")
	public int updateCompany(@Param("status")boolean status,@Param("id")String id);
}
